<%-- 
    Document   : login
    Created on : Dec 3, 2013, 9:53:41 PM
    Author     : Welcome
--%>
<%@page import="businesscard.DAO.UserDAO"%>
<%@page import="businesscard.DAO.GiohangDAO"%>
<%@page import="bc.entity.User"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link rel="stylesheet" href="style.css" type="text/css"/>  
        <script type="text/javascript" src="jquery/jquery-1.1.3.1.min.js"></script> 
        <script type="text/javascript" src="jquery/jquery-1.4.2.js"></script> 
        <script type="text/javascript" src="jquery/jquery-latest.js"></script>
        <script type="text/javascript" src="jquery/myjquery.js"></script>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

        <title>Hibernate Hello World!</title>

    </head>
    <body>
        <%
            HttpSession session1 = request.getSession();
            User usr = (User) session1.getAttribute("USER");
            if (usr != null) {
                String username = usr.getUser();
                UserDAO userDAO1 = new UserDAO();
                User user5 = userDAO1.getUser2(username);
                int id_user = user5.getIdUser();
        %>
        <div class="register"> 
            <font style="font-size: 14px" color="blue">
                Xin chào, <%= usr.getUser()%> 

                <button><image src="images/TAM.png"/></button>
                <div id="menu">
                    <li> <a href="trangcanhan.jsp" class="nevg">Trang cá nhân</a> </li>
                        <%
                            int role_name = usr.getQuyen().getIdQuyen();
                            if (role_name == 1 || role_name == 2) {%>
                    <li> <a href='indexadmin.jsp' class="nevg">Tới trang Admin</a></li>
                        <%                                    }
                        %>
                    <li> 
                        <form action="UserController" method="post">
                            <input type="submit" name="action" value="Logout" id="logout"/>
                        </form>
                    </li> 
                </div>

            </font>

        </div>
        <%
                            GiohangDAO gh=new GiohangDAO();
                               int count=gh.countLH(id_user);

        %>
        <div id="soluong"><%=count %> </div><a href="Giohang.jsp">Giỏ hàng</a>
        <% } else if (usr == null) {%>

        <div class="register">
            <a  class="showlogform" href="#">Đăng nhập |</a>
            <a class="orange" href="trangdangki.jsp">Đăng ký thành viên</a>
        </div> 
        <%}%>
        <div id="M_idlogin">
            <div id="borderidlogin">
                <div id="M_closelogin"></div>       
                <div id="contentidlogin" >
                    <div>
                        <form id="searchform" action="UserController" method="post">                   
                            <table border="0" width="90%" height="100%" text-align="center" id="tblregister">
                                <thead>
                                    <tr>
                                        <th class="txt_register" colspan="2">ĐĂNG NHẬP</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <td>Tên đăng nhập:</td>
                                        <td> <input name="txtUsername" id="valueSearch" type="text" size="30" value="" onkeyup="ResultSearch(this.value)" /> *</td>
                                    </tr>
                                    <tr>
                                        <td>Mật khẩu: </td>
                                        <td> <input name="txtPassword" id="valueSearch" type="password" size="30" value="" onkeyup="ResultSearch(this.value)" /> *</td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td><input type="submit" value="Login" name="action" id="button"/><input type="reset" value="Reset" name="reset" id="button"/> </td>
                                    </tr>
                                </tbody>
                            </table>

                            <div id="quenpass">
                                <a href="forgotpass.jsp">Bạn quên mật khẩu?</a>
                            </div>
                        </form>
                    </div>
                </div>

            </div>

        </div>
        <script>
                                            $("button").click(function() {
                                                $("#menu").slideToggle("fast");
                                            });

        </script>
    </body>
</html>
